package io.lkt.modules.sys.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import io.lkt.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.lkt.modules.sys.entity.BUserPromotionPaymentInfoEntity;
import io.lkt.modules.sys.service.BUserPromotionPaymentInfoService;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.R;



/**
 * 用户推广付款信息表
 *
 * @author xss
 * @email dustwas@163.com
 * @date 2019-04-15 10:53:10
 */
@RestController
@RequestMapping("/sys/buserpromotionpaymentinfo")
public class BUserPromotionPaymentInfoController {
    @Autowired
    private BUserPromotionPaymentInfoService bUserPromotionPaymentInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:buserpromotionpaymentinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bUserPromotionPaymentInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
        BUserPromotionPaymentInfoEntity bUserPromotionPaymentInfo = bUserPromotionPaymentInfoService.getById(id);

        return R.ok().put("bUserPromotionPaymentInfo", bUserPromotionPaymentInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BUserPromotionPaymentInfoEntity bUserPromotionPaymentInfo){
        bUserPromotionPaymentInfo.setCreateTime(new Date());
        bUserPromotionPaymentInfoService.save(bUserPromotionPaymentInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:buserpromotionpaymentinfo:update")
    public R update(@RequestBody BUserPromotionPaymentInfoEntity bUserPromotionPaymentInfo){
        ValidatorUtils.validateEntity(bUserPromotionPaymentInfo);
        bUserPromotionPaymentInfo.setModifyTime(new Date());
        bUserPromotionPaymentInfoService.updateById(bUserPromotionPaymentInfo);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:buserpromotionpaymentinfo:delete")
    public R delete(@RequestBody Integer[] ids){
        bUserPromotionPaymentInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
